@extends('layouts.layouts')
@section('title')
    <title>Bootstrap Admin</title>
@endsection

@section('content')
    <!-- Demo page code -->

    <div class="content">
        <div class="header">
            <ul class="breadcrumb">
                <li><a href="/ctype/list">课程分类</a> </li>
                <li class="active">添加分类</li>
            </ul>
        </div>
        <div class="main-content">
            
<ul class="nav nav-tabs">
  <li class="active"><a href="#home" data-toggle="tab">添加分类</a></li>
 <!-- <li><a href="#profile" data-toggle="tab">密码</a></li>-->
</ul>

<div class="row">
  <div class="col-md-4">
    <br>
    <div id="myTabContent" class="tab-content">
      <div class="tab-pane active in" id="home">
      <form id="tab" method="post" action="{{url('ctype/store')}}" enctype="multipart/form-data">
      <div class="form-group">
              <label>seo标题</label>
              <input type="text" name="seo_title" placeholder="seo标题" class="form-control">
        </div>
        <div class="form-group">
             <label>seo描述</label>
            <input type="text" name="seo_description" placeholder="seo描述" class="form-control">
        </div>
        <div class="form-group">
          <label>栏目</label>
          <input type="text" name="title" placeholder="请输入栏目名称" class="form-control">
        </div>
        <div class="form-group">
          <label>栏目说明</label>
          <input type="text" name="description" placeholder="请输入栏目说明如:构建私教及基础能力" class="form-control" />
        </div>
        <div class="form-group">
          <label>显示排序值</label>
          <input type="text" name="orderby" placeholder="请输入排序值默认0，由高到低" class="form-control" />
        </div>
        <div class="form-group">
        <label>上传图片</label>
		
		<div class="uploadfiley" style="display: block;position: relative;width: 120px;height: 40px;background: none repeat scroll 0 0 #428bca;color: #fff;cursor: pointer;text-align: center;line-height: 40px;">上传图片</div>
        <input type="file" name="cover_url" class="form-control"  style="display:none;"  onchange="showPreview(this)"/>
		 <img id="portrait" src="" style="display:none;width:150px;" class="img-thumbnail"/>
		
        </div>
		  <div class="form-group">
            <label>链接</label>
            <input type="text" name="path" class="form-control" placeholder="链接">
          </div>
        <div class="form-group first_cate">
            <label>上级栏目</label>
            <select name="pid" id="DropDownTimezone" class="form-control">
                <option value="0">无</option>
                 @if(is_array($type))
                        @foreach($type as $a)
                                 <option value="{{$a->id}}">{{$a->title}}</option>
                                @if(is_array($a->child))
                                    @foreach($a->child as $v)
                                        <option @if($v->id == $a->pid) selected @endif value="{{$v->id}}">&nbsp;&nbsp;├{{$v->title}}</option>
                                    @endforeach
                                @endif
                        @endforeach
                  @endif
            </select>
        </div>

        <div class="form-group">
            <label>状态</label>
            <select name="state" id="DropDownTimezone" class="form-control">
				  <option value="0">禁用</option>
				  <option value = "1" selected>显示</option>
            </select>
          </div>
			<input type="hidden" name="_token" value="{{csrf_token()}}"/>
 <div class="btn-toolbar list-toolbar">
      <button class="btn btn-primary btn-submit" type="submit"><i class="fa fa-save"></i> 保存</button>
    <!--  <a href="" data-toggle="modal" class="btn btn-danger">删除</a>-->
    </div>
        </form>
      </div>
    </div>


  </div>
</div>
 </div>
</div>
    <script src="lib/bootstrap/js/bootstrap.js"></script>
    <script type="text/javascript">
        $("[rel=tooltip]").tooltip();
        $(function() {
            $('.demo-cancel-click').click(function(){return false;});
        });

    </script>
	<script type="text/javascript">
	$(".uploadfiley").click(function(){
			$("input[type='file']").trigger('click');
	});
    function showPreview(source) {
      var file = source.files[0];
      if(window.FileReader) {
          var fr = new FileReader();
          console.log(fr);
          var portrait = document.getElementById('portrait');
          fr.onloadend = function(e) {
            portrait.src = e.target.result;
          };
          fr.readAsDataURL(file);
          portrait.style.display = 'block';
      }
    }
    /*$("#DropDownTimezone").change(function(){
        var value = $(this).val();
        $.get("/ctype/getCate",{id:value},function(data){
            console.log(data);
            if(data !== null) {
                $.each(JSON.parse(data), function (index, json) {

                    var str = "";
                    var str = str + '<div class="form-group two_cate"><label>一级栏目</label><select name="pid" id="DropDownTimezone" class="form-control">';
                    var str = str + ' <option value="' + json['id'] + '">' + json['title'] + '</option>';
                    var str = str + '</select></div>';

                    $(".first_cate").after(str);
                })
            }
        });
    })*/

</script>

@endsection
